package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import bean.NewsBean;
import bean.NotificationBean;

public class NewsDao {
		public List<NewsBean> getNews() throws ClassNotFoundException, SQLException {
			Connection conn = DBUtil.getConnection();
			PreparedStatement ps = conn.prepareStatement("select * from news order by id desc");
			ResultSet rs = ps.executeQuery();
			List<NewsBean> list = new ArrayList<NewsBean>();
			while(rs.next()) {
				NewsBean news = new NewsBean();
				news.setId(rs.getInt(1));
				news.setUserName(rs.getString(2));
				news.setContent(rs.getString(3));
				list.add(news);
			}
			return list;
  }
}
